package com.eve.springcloud.controller;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.eve.common.util.Jsons;
import com.eve.springcloud.service.FeignHystrixService;
import com.eve.springcloud.service.PaymentSFeignService;

/**
 * 使用OpenFeign
 * @author HXL
 * 20200511
 */
@RestController
public class PaymentFeignController {

	@Resource
	private PaymentSFeignService paymentFeignService;
	@Resource
	private FeignHystrixService hystrixService;
	
	@RequestMapping(value = "/dept/find/{deptId}", method = RequestMethod.GET)
	public @ResponseBody Jsons find(@PathVariable("deptId") Long deptId) {
		return paymentFeignService.findOne(deptId);
	}
	
	@RequestMapping(value = "/dept/feign/timeout", method = RequestMethod.GET)
	public @ResponseBody int timeoutTest() {
		
		return paymentFeignService.timeoutTest();
	}
	// Hystrix测试 20200512
	@RequestMapping(value = "/dept/hystrix/get/{id}", method = RequestMethod.GET)
	public @ResponseBody String hystrixGet(@PathVariable("id") Long id) {
		return hystrixService.findOne(id);
	}
	
	@RequestMapping(value = "/dept/hystrix/timeout/{id}", method = RequestMethod.GET)
	public @ResponseBody String hystrixTimeout(@PathVariable("id") Long id) {
		return hystrixService.timeoutTest(id);
	}
	
}
